package com.itheima.test;

/**
 * @Author 王加鑫
 * @Date 2021/4/14 19:29
 * @Version 1.0
 * 赋值运算符扩展
 */
public class OperatorDemo05 {

    /*
	   注意:扩展的赋值运算隐含了强制类型转换
	        short s = 1;
			s+=1 的效果等同于 s = (short)(s + 1)

	*/
    public static void main(String[] args) {
        //错误示范 错误: 不兼容的类型: 从int转换到short可能会有损失
        short s = 1;
        s = (short)(s + 1);
        System.out.println(s);

        //+=
        byte b = 10;
        b+=1;
        System.out.println(b);

        //-=
        int i = 100;
        i-=1;
        System.out.println(i);

        //*=
        int a = 10;
        a*=10;
        System.out.println(a);

        // /=
        int num = 1000;
        num/=500;
        System.out.println(num);

        //%=
        int num1 = 10;
        num1%=3;
        System.out.println(num1);


    }
}
